'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''


#import org.apache.jena.graph.FrontsNode;

'''
 * Interface covering RDF resources and literals. Allows probing whether a
 * node is a literal/[blank, URI]resource, moving nodes from model to model,
 * and viewing them as different Java types using the .as() polymorphism.
'''
from abc import ABC, abstractmethod

class RDFNode(ABC):
    '''
     * Answer a String representation of the node.  The form of the string
     * depends on the type of the node and is intended for human consumption,
     * not machine analysis.
    '''
    #@Override
    # param 
    # result String
    @abstractmethod
    def toString(self):
        pass

    '''
     * Answer true iff this RDFNode is an anonymous resource. Useful for
     * one-off tests: see also visitWith() for making literal/anon/URI choices.
    '''
    # param 
    # result boolean
    @abstractmethod
    def isAnon(self):
        pass

    '''
     * Answer true iff this RDFNode is a literal resource. Useful for
     * one-off tests: see also visitWith() for making literal/anon/URI choices.
    '''
    # param 
    # result boolean
    @abstractmethod
    def isLiteral(self):
        pass

    '''
     * Answer true iff this RDFNode is an named resource. Useful for
     * one-off tests: see also visitWith() for making literal/anon/URI choices.
    '''
    # param 
    # result boolean
    @abstractmethod
    def isURIResource(self):
        pass

    '''
     * Answer true iff this RDFNode is a URI resource or an anonymous
     * resource or a statement term (ie is not a literal). Useful for one-off tests: see also
     * visitWith() for making literal/anon/URI choices.
    '''
    # param 
    # result boolean
    @abstractmethod
    def isResource(self):
        pass

    '''
     * Answer true iff this RDFNode is a resource representing an RDF-star triple term.
    '''

    # param 
    # result boolean
    @abstractmethod
    def isStmtResource(self):
        pass

    '''
     * RDFNodes can be converted to different implementation types. Convert
     * this RDFNode to a type supporting the <code>view</code>interface. The
     * resulting RDFNode should be an instance of <code>view</code> and should
     * have any internal invariants as specified.
     * <p>
     * If the RDFNode has no Model attached, it can only be .as()ed to
     * a type it (this particular RDFNOde) already has.
     * <p>
     * If the RDFNode cannot be converted, an UnsupportedPolymorphism
     * exception is thrown..
    '''
    # param Class<T> view
    # result <T extends RDFNode> T
    # @abstractmethod
    # def as(self, view):
    #     pass

    def asClass(self, clazz):
        pass

    '''
     * Answer true iff this RDFNode can be viewed as an instance of
     * <code>view</code>: that is, if it has already been viewed in this
     * way, or if it has an attached model in which it has properties that
     * permit it to be viewed in this way. If <code>canAs</code> returns
     * <code>true</code>, <code>as</code> on the same view should
     * deliver an instance of that class.
    '''
    # param Class<T> view
    # result <T extends RDFNode> boolean
    # @abstractmethod
    # def canAs(self, view):
    #     pass

    '''
     * Return the model associated with this resource. If the Resource
     * was not created by a Model, the result may be null.
     *
     * @return The model associated with this resource.
    '''
    # param 
    # result Model
    @abstractmethod
    def getModel(self):
        pass

    '''
     * Answer a .equals() version of this node, except that it's in the model
     * <code>m</code>.
     *
     * @param m a model to move the node to
     * @return this, if it's already in m (or no model), a copy in m otherwise
    '''
    # param Model m
    # result RDFNode
    @abstractmethod
    def inModel(self, m):
        pass

    '''
     * Apply the appropriate method of the visitor to this node's content and
     * return the result.
     *
     * @param rv an RDFVisitor with a method for URI/blank/literal nodes
     * @return the result returned by the selected method
    '''
    # param RDFVisitor rv
    # result Object
    # @abstractmethod
    # def visitWith(self, rv):
    #     pass

    '''
     * If this node is a Resource, answer that resource otherwise throw an
     * exception.
    '''
    # param 
    # result Resource
    @abstractmethod
    def asResource(self):
        pass

    '''
     * If this node is a Literal, answer that literal otherwise throw an
     * exception.
    '''
    # param 
    # result Literal
    @abstractmethod
    def asLiteral(self):
        pass

    '''
     * Answer the Node associated with this object.
    '''
    @abstractmethod
    def asNode(self):
        pass
